package com.xinchao.ck_mips.http.client;

import com.xinchao.ck_mips.BuildConfig;
import com.xinchao.ck_mips.constant.CK;
import com.xinchao.ck_mips.http.api.ApiService;
import com.xinchao.ck_mips.utils.ShareUtil;
import com.xinchao.rxtools.rxhttp.RxHttpFactory;

/**
 * Created by wq .
 */

public class RetrofitClient {
    private static RetrofitClient sRetrofitClient;
    private ApiService mApiService;

    private RetrofitClient() {
        mApiService = RxHttpFactory.getRxHttp(ShareUtil.getInstance().getString(CK.CK_HOST, BuildConfig.BASE_URL)).create(ApiService.class);
    }

    public static RetrofitClient getInstance() {
        if (sRetrofitClient == null) {
            synchronized (RetrofitClient.class) {
                if (sRetrofitClient == null) {
                    sRetrofitClient = new RetrofitClient();
                }
            }
        }
        return sRetrofitClient;
    }

    public static void setNull() {
        sRetrofitClient = null;
    }

    public ApiService getApiService() {
        return mApiService;
    }
}
